<%- include header %>
<ul class="nav nav-pills">
    <li><a href="/mySchedule">日程管理</a></li>
    <li class="active"><a href="/orderPartner">预约语伴</a></li>
    <li ><a href="/orderList">预约列表</a></li>
    <li><a href="/myOrderList">我的预约</a></li>
</ul>
<table class="table table-bordered table-striped table-condensed table-hover" >
    <tr>
        <th class="span2">好友昵称</th>
        <th class="span2">性别</th>
        <th class="span2">年龄</th>
        <th class="span2">操作</th>
    </tr>
    <% datas.forEach(function(data,index){ %>
    <tr>

        <td>
            <a href="/partnerCenter?username=<%-data.username%>"><%- data.nickname %></a>
        </td>
        <% if(data.gender==1){ %>
        <td>
            男
        </td>
        <% }else{ %>
        <td>
            女
        </td>
        <% } %>
        <td>
            <%- data.age %>
        </td>
            <td>
            <a class="btn btn-danger btn-small" href="/partnerSchedule?id=<%- data._id %>">查看好友日程</a>
        </td>
    </tr>
    <% }) %>
</table>
<div class="span12">
    <div id="page1"></div>
</div>
<%- include footer %>
<script>

    $(function(){
        //获得浏览器参数

        $.extend({
            getUrlVars: function(){
                var vars = [];
                var hash;
                var hashes = window.location.href.slice(window.location.href.indexOf('?') + 1).split('&');
                console.log(hashes);
                for(var i = 0; i < hashes.length; i++){
                    hash = hashes[i].split('=');
                    vars.push(hash[0]);
                    vars[hash[0]] = hash[1];
                }
                return vars;
            },
            getUrlVar: function(name){
                return $.getUrlVars()[name];
            }
        });

        //封装浏览器参数
        var composeUrlParams=function(){
            var param='';
            $.each($.getUrlVars(), function(i, item) {
                if(item!='num'){
                    var val=$.getUrlVar(item);
                    if(val) param += "&" + item+"="+val;
                }
            });
            return param;
        }
        var options = {
            currentPage:<%- page.num %>,                //当前页，css样式同其他页不同
            totalPages:<%- page.pageCount %>,           //总页数
            numberOfPages:5,                            //导航最多显示页数
            pageUrl: function(type, page, current) {    //页面跳转
                if(page!=<%- page.num %>){
                    return "/orderPartner?num="+ page+composeUrlParams();
                }

            }
        }
        $('#page1').bootstrapPaginator(options);
        WdatePicker({eCont:'showDate',onpicked:function(dp){
            alert('你选择的日期是:'+dp.cal.getDateStr());
        }
        })
    })
</script>